<?php
/*
Plugin Name: WP e-Commerce - Facebook Like Button
Plugin URI: http://www.visser.com.au/wp-ecommerce/plugins/facebook-like-button/
Description: Enable visitors to your WP e-Commerce store to make connections to Product pages and share content back to their friends on Facebook with one click.
Version: 1.6.9
Author: Visser Labs
Author URI: http://www.visser.com.au/about/
License: GPL2
*/

load_plugin_textdomain( 'wpsc_fl', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );

include_once( 'includes/functions.php' );

include_once( 'includes/common.php' );

switch( wpsc_get_major_version() ) {

	case '3.7':
		include_once( 'includes/release-3_7.php' );
		break;

	case '3.8':
		include_once( 'includes/release-3_8.php' );
		break;

}

$wpsc_fl = array(
	'filename' => basename( __FILE__ ),
	'dirname' => basename( dirname( __FILE__ ) ),
	'abspath' => dirname( __FILE__ ),
	'relpath' => basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ )
);

$wpsc_fl['prefix'] = 'wpsc_fl';
$wpsc_fl['name'] = __( 'Facebook Like Button for WP e-Commerce', 'wpsc_fl' );
$wpsc_fl['menu'] = __( 'Facebook Like Button', 'wpsc_fl' );

if( is_admin() ) {

	include_once( 'includes/install.php' );
	register_activation_hook( __FILE__, 'wpsc_fl_install' );

	include_once( dirname( __FILE__ ) . '/includes/update.php' );

	function wpsc_fl_html_page() {

		global $wpsc_fl;

		wpsc_fl_template_header();
		$action = wpsc_get_action();
		switch( $action ) {

			case 'update':
				if( isset( $_POST['show_faces'] ) )
					$show_faces = 1;
				else
					$show_faces = 0;
				$position = $_POST['position'];
				$width = $_POST['width'];
				$colour_scheme = $_POST['colour_scheme'];
				$display_productspage = $_POST['display_productspage'];
				$display_singleproduct = $_POST['display_singleproduct'];

				update_option( 'wpsc_fl_position', $position );
				update_option( 'wpsc_fl_show_faces', $show_faces );
				update_option( 'wpsc_fl_width', $width );
				update_option( 'wpsc_fl_colour_scheme', $colour_scheme );
				update_option( 'wpsc_fl_display_productspage', $display_productspage );
				update_option( 'wpsc_fl_display_singleproduct', $display_singleproduct );

				$message = __( 'Settings saved', 'wpsc_fl' );
				$output = '<div class="updated settings-error"><p><strong>' . $message . '</strong></p></div>';
				echo $output;
				wpsc_fl_options_form();
				break;

			default:
				wpsc_fl_options_form();
				break;

		}
		wpsc_fl_template_footer();

	}

	function wpsc_fl_options_form() {

		$positions = wpsc_productpage_positions();

		$position = get_option( 'wpsc_fl_position' );
		$display_productspage = get_option( 'wpsc_fl_display_productspage' );
		$display_singleproduct = get_option( 'wpsc_fl_display_singleproduct' );
		$show_faces = get_option( 'wpsc_fl_show_faces' );
		$width = get_option( 'wpsc_fl_width' );
		$colour_scheme = get_option( 'wpsc_fl_colour_scheme' );

		include( 'templates/admin/wpsc-fl_admin_settings.php' );

	}

} else {

	include_once( 'includes/template.php' );
	include_once( 'includes/legacy.php' );

	$position = get_option( 'wpsc_fl_position' );
	if( $position )
		add_action( $position, 'wpsc_fl_init' );
	else
		add_action( 'wpsc_product_addons', 'wpsc_fl_init' );

}
?>
